package model.tests;

import static org.junit.Assert.assertTrue;
import model.elements.Bomb;
import model.elements.attributes.Coordinate2D;
import model.elements.commands.ElementCommandFactory;
import model.elements.factory.ElementsFactory;
import model.elements.factory.ModelElementsDefaultFactory;
import model.elements.states.weapon.BombEquipped;
import model.elements.states.weapon.ElementWeaponState;
import model.exceptions.MaxAmmoUsed;
import model.exceptions.ModelExceptions;
import model.exceptions.WeaponCouldNotBePlaced;
import model.map.ElementsMap;

import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;

// TODO: Auto-generated Javadoc
/**
 * The Class BombEquippedStateTest.
 */
public class BombEquippedStateTest {

	/** The bomb equipped test. */
	ElementWeaponState bombEquippedTest;
	
	/** The test map. */
	static ElementsMap testMap = new ElementsMap(10,10);
	
	/** The test factory. */
	static ElementsFactory testFactory = new ModelElementsDefaultFactory();
	
	/**
	 * Sets the up before class.
	 *
	 * @throws Exception the exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {		
		ElementCommandFactory.setup(testMap, testFactory);
	}
	
	/**
	 * Tear down.
	 *
	 * @throws Exception the exception
	 */
	@After
	public void tearDown() throws Exception 
	{		
		testMap.clear();
	}
	
	
	/**
	 * Test get weapon.
	 *
	 * @throws ModelExceptions the model exceptions
	 */
	@Test
	public void testGetWeapon() throws ModelExceptions {
		
		bombEquippedTest = new BombEquipped(1);
		assertTrue( bombEquippedTest.getWeapon( new Coordinate2D(0,0), testFactory ) instanceof Bomb );
	}
	
	/**
	 * Test max ammo used.
	 *
	 * @throws ModelExceptions the model exceptions
	 */
	@Test (expected = MaxAmmoUsed.class)
	public void testMaxAmmoUsed() throws ModelExceptions {
		
		bombEquippedTest = new BombEquipped(1);
		bombEquippedTest.getWeapon( new Coordinate2D(0,0), testFactory );
		bombEquippedTest.getWeapon( new Coordinate2D(1,0), testFactory );
		
	}
	
	/**
	 * Test weapon could not be placed.
	 *
	 * @throws ModelExceptions the model exceptions
	 */
	@Test (expected = WeaponCouldNotBePlaced.class)
	public void testWeaponCouldNotBePlaced() throws ModelExceptions {
		
		bombEquippedTest = new BombEquipped(2);
		bombEquippedTest.getWeapon( new Coordinate2D(0,0), testFactory );
		bombEquippedTest.getWeapon( new Coordinate2D(0,0), testFactory );
		
	}

}
